home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 2.iso
/
STUTTGART
/
UTIL
/
SCREEN
/
LIFEGUARD
/
!Lifeguard
/
Documents
/
FileSpec
< prev
next >
Wrap
Text File
|
1992-09-30
|
11KB
|
290 lines
File format for Lifeguard 1.08 Effects Modules (&400, GuardMod)
===============================================================
===========================================================================
Offset Length Contents
(dec) (dec)
---------------------------------------------------------------------------
0 8 GUARDMOD (&52415547, &444F4D44)
8 4 Version number of Lifeguard that this effect module was
written for, times by 100 (eg. 1.08*100=108)
12 4 Flags (see below)
16 4 Required mode for effect (see below)
20 28 Short name of the effect (padded with zeros)
48 34 First line of long name of the effect (padded with zeros)
82 34 Second line of long name of the effect (padded with zeros)
116 34 Third line of long name of the effect (padded with zeros)
150 34 Author's name (padded with zeros)
184 4 B initialise_code
188 4 B vsync_code
192 4 B finalise_code
196 4 Pointer to options window template, 0 if no window
*** All values below here can be ommitted if offset 196 is 0 ***
200 4 Pointer to routine to set options window icons \
204 4 Pointer to routine to read options window icons | see below
208 4 Pointer to routine to be called on Poll event /
===========================================================================
NB: Any of the entry points can be left out (by replacing them with
-- MOVS PC,R14) if you wish. If the vsync_code entry is left out, however,
all that will happen is that the screen will turn black (because
Lifeguard will change mode to the one you have asked for, call the
intialise code and then not call your code again until it gets to the
finalise entry).
R2-R5 can be used for storing things in. These will start as all 0 on
the call to Initialise, then they will remain constant from call to call
until the Finalise entry is called, after which the values are
forgotten.
Remember that your code must be fully relocatable, as it will move about
when Lifeguard is first loaded, and when the user removes effects above
your one in the effects file.
You should try to make your code mode-independent (see below). You can
use calls to ColourTrans, as this is guaranteed to be loaded.
Initialise code
---------------
On entry:
R0 = Version number of Lifeguard*100
R1 = Current screen mode
R2-R5 = 0
R6 = Address of screen parameters block (see below)
R13 = Stack
On exit:
R0 = 0 if effect refuses to initialise
R2-R5 = Work registers
All registers above R5 (R6-R13) must be preserved
This code is called once, when the screen is due to be 'blanked'. It
should claim any workspace needed and check that everything is OK for the
effect to be displayed. If the effect cannot start up for any reason, R0
should be 0 on exit. Any other value than 0 will be assumed to mean that the
effect has initialised OK. The code MUST preserve ALL registers other than
R0-R5.
Note that, although Lifeguard will try to change to the mode that you
request, it may not be able to, eg. because of insufficient memory.
Therefore, if your code is not guaranteed to work in ALL modes, it should
check the mode given in R1, and refuse to initialise if it doesn't like it.
VSync code
----------
On entry:
R0 = 0
R2-R5 = Work registers
R6 = Address of screen parameters block (see below)
R13 = Stack
On exit:
R0 = -1 means effect has finished
R2-R5 = New work registers
All registers above R5 (R6-R13) must be preserved
This code is called on every available VSync while the effect is being
displayed. This code should display the effect, move it, whatever. The code
MUST preserve ALL registers.
If R0 = -1 on exit then Lifeguard will finalise your effect and choose
another one. This is used by 'Fade' to start another effect when the desktop
screen has faded out.
Remember that you are still in the Desktop, so the code should be as
legal as possible. You can write directly to the screen, if you are sure
of the mode, and if you use legal calls to work out the screen address.
Finalise code
-------------
On entry:
R2-R5 = Work registers
R6 = Address of screen parameters block (see below)
R13 = Stack
On exit:
All registers must be preserved
This code is called when the effect is being closed down. It should
release any workspace, etc. It MUST preserve ALL registers.
Mode
----
Normally, Lifeguard will attempt to change to the mode specified in the
effect's header, by using a Wimp_SetMode followed by a VDU 22,mode to reset
the palette, etc. If you specify the mode as -1 then the mode will not be
changed - this may be used in conjuction with bit 2 of the flags (see below).
Note that if you set the mode number to -1 then the screen will still be
wiped, unless you do set bit 2 of the flags.
Note that you should try to make your effect mode-independent - ie. set
the required mode to -1. The main reasons for this are that if you change to
a lower-resolution mode then the windows all move a little bit, and if you
move to a smaller screen size mode then the windows can move quite a lot.
Screen parameters block
-----------------------
Lifeguard will pass you a pointer in R6 to a block of memory containing
information about the current screen mode. The format of the block is as
follows:
R6 + 0 = Number of colours (ie. 2,4,16 or 256)
R6 + 4 = XEigFactor (number of bits to shift a pixel value leftwards to
get the value in OS Units - eg. 1 for mode 12).
R6 + 8 = YEigFactor (similarly for Y direction)
R6 + 12 = Number of pixels across (eg. 640 for mode 12)
R6 + 16 = Number of pixels down (eg. 256 for mode 12)
R6 + 20 = Screen width in OS Units (eg. 1280 for mode 12)
R6 + 24 = Screen height in OS Units (eg. 1024 for mode 12)
R6 + 28 = Address of start of displayed screen (eg. &1FEC000)
R6 + 32 = Screen mode (eg. 12)
R6 + 36 = One horizontal pixel in OS Units (ie. 1<<XEig) (eg. 2)
R6 + 40 = One vertical pixel in OS Units (ie. 1<<YEig) (eg. 4)
R6 + 44 = Address of screen fade routine (see below)
Screen fade routine
-------------------
This routine, provided by Lifeguard, can be used to dim the screen. This
can be used as a normal fade to black, or can be made to go only half way.
This can be useful for effects which leave the original desktop screen in
place and move it around (eg. RainyDay, Puzzle), as if the original screen
was largely a bright colour then the effect wouldn't help much. Call the
routine with the start position in R0 and the end position in R1. The
positions are the 'degrees of fade', 0-15 with 0 as black and 15 as normal
colours.
Options window
--------------
From version 1.06, Lifeguard will allow your effect to have an options
window which allows the user to customise your effect. The template should be
in your effect module (see the example effects for a routine to include the
template in your file).
Icon 0 should be an 'OK' button. Icon 1 should be a 'Cancel' button.
Apart from this the window can contain anything you like. Remember that you
can use WimpExtension 3D icons and pointer changes in your window if you
don't set the 'Auto-Redraw' bit. The 'ptr_menu' and 'ptr_write' pointers are
guaranteed to be available. Part of the WimpExtension manual is included in
the file 'WimpExtMan' so you can use these features. You can also use the
icon-handling features of WimpExtension.
You must provide 3 routines for dealing with your window:
Window-Set code
---------------
On entry:
R0 = Window handle
This routine should set the window's icons according to the status of
stored information in the effect module. The window will not be visible when
this routine is called.
File-Set code
-------------
On entry:
R0 = Window handle
This routine should set the stored information in the effect module
according to the window's icons.
Event code
----------
On entry:
R0 = Mouse_Click (6) or Menu_Selection (9)
R1 = Pointer to Poll block
On exit:
If R0 = 'MENU' (&554E454D) then
R1 = pointer to menu block
R2 = X Pos for menu
R3 = Y Pos for menu
This routine should deal with mouse clicks and menu selections in your
window. You can create menus by exiting with the parameters for
Wimp_CreateMenu in R1, R2, R3, and 'MENU' in R0.
Flags
-----
===========================================================================
Bit Meaning if set
---------------------------------------------------------------------------
0 Effect is enabled
1 Effect is selected
2 Needs the desktop screen in place
3 Inhibit dimming
3-31 Reserved; MUST BE 0
===========================================================================
NB: Bits 0 and 1 must be set to 0 in the EffectMod file. These bits are set
-- by Lifeguard in the Effects file if the effect is enabled or selected.
The only bits that should currently be set by effects writers are bits 2
and 3. If bit 2 is set then Lifeguard will not wipe the screen before
starting the effect. This is so that you can write effects that use the old
screen, such as 'Puzzle'. If bit 3 is set than Lifeguard will never dim the
screen before entering your effect. This is for effects like 'Fade' which
wipe the screen anyway.
GuardRM
-------
The Guard relocatable module is used to detect keypresses and mouse
clicks. It also provides an emergency or out-of-desktop screen blanker which
simply turns the screen black. It provides several SWIs. Apart from the two
below, you SHOULD NOT USE the SWIs, even if you think you know what they do
(it's pretty obvious from their names). You shouldn't have to use them
anyway - anything like changing the blanking delay should be done by the
user, not by another program.
There are two SWIs you can use: Guard_ReadRandom and Guard_LargeRandom.
These are outlined below:
SWI Guard_ReadRandom
On entry:
R0 = Maximum limit (1-8192)
On exit:
R0 = Random number 0-limit
Flags preserved
This SWI returns a random number in the range 0-R0. The maximum limit is
8192. The number is brought within the correct range simply by repeatedly
subtracting the range until the number is within the range. If your range is
a power of two therefore, it is quicker to set a range of 8192 (or anything
larger) and then ANDing the number to get it in range.
The random number routine is very simple, but should be good enough for
most purposes. It is seeded with the monotonic time when the Guard module is
first loaded.
SWI Guard_LargeRandom
On entry:
R0 = Maximum limit (1-65535)
On exit:
R0 = Random number 0-limit
Flags preserved
This is the same as Guard_ReadRandom, except that it can produce numbers
in the range 0-65535. The penalty for this is that it is slightly slower.
Therefore ReadRandom should be used where possible; only use LargeRandom
where you have to.